<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Acceso extends CI_Controller {

    public function index() {
       // $this->load->view('estructura/head');
        $this->load->view('login');
       // $this->load->view('estructura/footer');
    }

    public function validar() {
        $usuario = $_POST['usu'];
        $password = $_POST['pass'];
        $this->load->model("usuario_model");
        $result = $this->usuario_model->logeo_personal($usuario, $password);

        if ($result) {
            $sesion_data = array(
                'codigo' => $result{0}['id_pers'],
                'nombre' => $result{0}['nom_per'],
                'apellido' => $result{0}['ape_per'],
                'direccion' => $result{0}['dir_per'],
                'usuario' => $usuario,
                'clave' => $password
            );
            $this->session->set_userdata($sesion_data);
            $data['nom'] = $this->session->userdata['nombre'];
            $data['ape'] = $this->session->userdata['apellido'];

            $this->load->view('estructura/head');
            $this->load->view('intranet/intranet_view',$data);
            $this->load->view('estructura/footer');
        } else {
            $this->index();
        }
    }

}